[#include "/app/common/layout/__backstagemainlayout.html"/]
[#assign pageJavascript]
<!-- page specific plugin scripts -->
<script src="${ContextPath}/admin/assets/js/jquery.dataTables.js"></script>
<script src="${ContextPath}/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
<script src="${ContextPath}/admin/assets/js/data-tables/dataTables.tableTools.js"></script>
<!-- inline scripts related to this page -->
<script type="text/javascript">
$(function(){
    $('#orders').dataTable({
    	"bPaginate": true,
    	"language": {
           "lengthMenu": '每页 <select>'+
             '<option value="10">10</option>'+
             '<option value="20">20</option>'+
             '<option value="50">50</option>'+
             '<option value="-1">全部</option>'+
             '</select> 条记录'
         },
         "iDisplayLength": 10,
         
    });
});

$(".query").click(function(){
	$.ajax({
		type:"post",
		url:"${ContextPath}/admin/queryOrder",
		data:{
			"orderid":$(this).attr("orderid"),
		},
		dataType:"json",
		success:function(result){
			$("#queryModal").modal();
			$("#comments").html("");
			$("#orderid").attr("value",result.order.id);
			$("#title").attr("value",result.order.title);
			$("#description").text(result.order.description);
			$("#type_name").attr("value",result.order.type_name);
			if(result.commentList.length>0){
				$("#comments").append('<thead><tr><th width="10%">编号</th><th width="15%">提交者</th><th width="60%">内容</th><th width="10%">操作</th></tr></thead>');
			}
			$("#comments").append("<tbody>");
			for (var i = 0; i < result.commentList.length; i++) {
				$("#comments").append('<tr><td>'+result.commentList[i].id+'</td>'+'<td>'+result.commentList[i].ufull_name+'</td>'+'<td nowrap title='+result.commentList[i].context+'><div style="overflow: hidden; width: 400px;">'+result.commentList[i].context+'</div></td><td><a class="btn btn-minier btn-danger red comment" commentid='+result.commentList[i].id+'>删除</a></td></tr>');
			}
			$("#comments").append('</tbody>');
		},
		error:function(){
			alert("error"+$("#orderid").attr("value"));
		}
	});
});

$(".delete").click(function(){
	var orderid=$(this).attr("orderid");
	alertModal(orderid);
	$("#alertModal").modal();
	$("#orderid").attr("value",orderid);
});
   
$("#sure").click(function(){
	$.ajax({
		type:"post",
		url:"${ContextPath}/admin/deleteOrder",
		data:{
			"orderid":$("#orderid").attr("value")
		},
		dataType:"json",
		success:function(result){
			location.reload();
		},
		error:function(){
			alert("error"+$("#orderid").attr("value"));
		}
	
	});
});

function alertModal(msg){
	$("#modal-title-order").html("提示!");  
	$("#modal-body-order").html("是否确定删除"+msg+"号工单？");  
}
</script>
[/#assign]
[#assign pageCss]
<link rel="stylesheet" href="${ContextPath}/admin/assets/css/data-tables/dataTables.tableTools.css" />
[/#assign]

[@mainlayout pageJavascript=pageJavascript pageCss=pageCss currentMenu="orderFlag-ordersListFlag"]

<div class="page-header">
	<h1>
		工单管理 
		<small> <i class="ace-icon fa fa-angle-double-right"></i> 动态工单</small>
	</h1>
</div>
<div class="row">
	<div class="col-xs-12">
		<!-- PAGE CONTENT BEGINS -->
		
		<div class="row">
			<div class="col-xs-12">
				<div>
				<div>
					<a id="exporter"  class="btn btn-primary  blue" href="${ContextPath}/admin/exporter">导出</a>
				</div>
					<table id="orders" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th>序号</th>
								
								<th>标题</th>
								<th class="hidden-480">申报部门</th>
								<th class="hidden-480">申报人</th>
								<th><i class="ace-icon fa fa-clock-o bigger-110 hidden-480"></i>申报时间</th>
								<th class="hidden-480">当前状态</th>
								<th>工单编号</th>
								<th></th>
							</tr>
						</thead>
						
						<tbody>
							[#list ordersList as order]
							<tr>

								<td>${order_index+1}</td>
								
								<td>${(order.title)!}</td>
								<td class="hidden-480">${(order.off_paname)!}</td>
								<td class="hidden-480">${(order.off_user)!}</td>
								<td>${(order.offer_at)!}</td>

								<td class="hidden-480">
									<b>
									[#if order.deleted_at??]
									<span class="red">已撤销</span>
									[#elseif order.status=0]
									<span class="green">已处理</span>
									[#elseif order.status=1]
									<span class="orange">处理中</span>
									[#elseif order.status=2]
									<span class="gray">未处理</span>
									[/#if]
									</b>
								</td>
								<td>${(order.id)!}</td>

								<td>
									<div class="hidden-sm hidden-xs action-buttons">
										<a class="btn btn-minier btn-primary  blue query" href="#" orderid="${(order.id)!}"> 查看</a> 
										<a class="btn btn-minier btn-danger red delete" href="#" orderid="${(order.id)!}"> 删除</a>
									</div>

									<div class="hidden-md hidden-lg">
										<div class="inline position-relative">
											<button class="btn btn-minier btn-yellow dropdown-toggle"
												data-toggle="dropdown" data-position="auto">
												<i class="ace-icon fa fa-caret-down icon-only bigger-120"></i>
											</button>

											<ul
												class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
												<li>
													<a href="#" class="tooltip-info" data-rel="tooltip"  title="查看"> 
														<span class="blue"> 
																<i class="ace-icon fa fa-search-plus bigger-120"></i>
														</span>
													</a>
												</li>

												<li>
													<a href="#" class="tooltip-error" data-rel="tooltip" title="删除"> 
														<span class="red">
															<i class="ace-icon fa fa-trash-o bigger-120"></i>
														</span>
													</a>
												</li>
											</ul>
										</div>
									</div>
								</td>
							</tr>
							[/#list]
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="aaa"></div>
		<!-- PAGE CONTENT ENDS -->
	</div>
	<!-- /.col -->
</div>
<!-- pageContent END -->
[#include "/app/admin/order/_model.html" /]
[/@mainlayout]